package com.ilop.sthome.ui.activity.login;

import android.content.Context;
import android.os.Bundle;
import android.os.IBinder;
import android.text.InputFilter;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import com.alibaba.sdk.android.openaccount.ui.ui.RegisterFillPasswordActivity;
import com.alibaba.sdk.android.openaccount.ui.widget.NetworkCheckOnClickListener;
import com.siterwell.familywellplus.R;

/**
 * @author skygge
 * @date 2020-03-19.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：账号注册设置密码页面
 */
public class RegisterPasswordAliActivity extends RegisterFillPasswordActivity {

    @Override
    protected String getLayoutName() {
        return "activity_register_password_ali";
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.mToolBar.setVisibility(View.GONE);
        this.passwordInputBox.getEditText().setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});
        findViewById(R.id.iv_register_pwd_back).setOnClickListener(view -> finish());
        this.next.setText(getResources().getText(R.string.phone_register_page_title));
        this.next.setOnClickListener(new NetworkCheckOnClickListener() {
            public void afterCheck(View v) {
                hideSoftKeyboard();
                resetPassword();
            }
        });
    }

    /**
     * hide inputMethod
     */
    protected void hideSoftKeyboard() {
        InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
        if(inputMethodManager != null ) {
            View localView = this.getCurrentFocus();
            if(localView != null && localView.getWindowToken() != null ) {
                IBinder windowToken = localView.getWindowToken();
                inputMethodManager.hideSoftInputFromWindow(windowToken, 0);
            }
        }
    }
}
